package csu.ssd.student;

import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.Optional;

public class ScoreController {

    @FXML
    private Button questionButton;

    @FXML
    private Button submitButton;

    @FXML
    private Button leftGradeButton;

    @FXML
    private Button backButton;

    @FXML
    private AnchorPane RightPane;

    @FXML
    private Button buttonSetRightPane;

    @FXML
    private Button save;


    @FXML
    void setRightPaneVisible(ActionEvent event) {
        RightPane.setVisible(true);
    }

    @FXML
    void haveQuestion(ActionEvent event) {
        //对话框 Alert Alert.AlertType.CONFIRMATION：反问对话框
        Alert alert1 = new Alert(Alert.AlertType.INFORMATION);
        //设置对话框标题
        alert1.setTitle("疑问解答");
        //设置内容
        alert1.setHeaderText("教学评价是对教师工作现实的或潜在的价值做出判断的活动，你需要结合本学期的切身经历，" +
                "给予老师一个真实、中肯的评价。所以请大家负责任地填写。");
        //显示对话框
        Optional<ButtonType> result = alert1.showAndWait();
        //如果点击OK
        if (result.get() == ButtonType.OK){
            // ... user chose OK
            alert1.close();
            //否则
        } else {
            event.consume();
        }
    }

    @FXML
    void back1(ActionEvent event) {
        AnchorPane borderPane = null;
        try {
            borderPane = FXMLLoader.load(this.getClass().getResource("main.fxml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        Stage stage = new Stage();
        Scene scene = new Scene(borderPane);

        stage.setScene(scene);
        stage.setTitle("成绩页面");

        stage.show();

        ShouyeController.scoreStage.close();
    }

    @FXML
    void back2(ActionEvent event) {
        ShouyeController.scoreStage.close();
    }

    @FXML
    void submitAction(ActionEvent event) {

        //对话框 Alert Alert.AlertType.CONFIRMATION：反问对话框
        Alert alert2 = new Alert(Alert.AlertType.CONFIRMATION);
        //设置对话框标题
        alert2.setTitle("提交提示");
        //设置内容
        alert2.setHeaderText("确认提交吗？");
        //显示对话框
        Optional<ButtonType> result = alert2.showAndWait();
        //如果点击OK
        if (result.get() == ButtonType.OK){
            // ... user chose OK
            ShouyeController.scoreStage.close();
            //否则
        } else {
            event.consume();
        }

    }

    @FXML
    void saveIf(ActionEvent event) {
        //对话框 Alert Alert.AlertType.CONFIRMATION：反问对话框
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        //设置对话框标题
        alert.setTitle("提示");
        //设置内容
        alert.setHeaderText("保存成功");
        //显示对话框
        Optional<ButtonType> result = alert.showAndWait();
        //如果点击OK
        if (result.get() == ButtonType.OK){
            // ... user chose OK
            alert.close();
            //否则
        } else {
            event.consume();
        }
    }


}

